package com.turing.manage.login;

import java.sql.SQLException;
import java.sql.Types;
import java.util.Map;

import com.turing.dao.Dao;
import com.turing.dao.DaoImpl;
/**
 * @desc   登录模块的M层
 * @author fx
 * @time   2021-12-11
 */
public class LoginService {
	
	Dao dao = new DaoImpl();
	
	/**
	 * @desc  1.查询：通过管理员姓名和密码查询
	 * @param name
	 * @param pass
	 * @return
	 * @throws SQLException 
	 * @throws ClassNotFoundException 
	 */
	public Map<String, Object> queryByNameAndPass(String name, String pass) throws ClassNotFoundException, SQLException {
		//return dao.executeQueryForMap(" select * from manager where manager_name='"+name+"' and manager_pass='"+pass+"'   ");
		
		String sql = "select * from manager where manager_name=? and manager_pass=?";
		
		//1.指定sql语句中?的数据类型
		int[] types = new int[2];
		types[0] = Types.VARCHAR;
		types[1] = Types.VARCHAR;
		
		//2.指定sql语句中?的值
		Object[] values = new Object[2];
		values[0] = name;
		values[1] = pass;
		
		return dao.executeQueryForMap(sql,types,values);
	}

}
